﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace FTchina.SMSServer
{
    public class work
    {
        public int State = 0;//0-没有开始,1-正在运行,2-成功结束,3-失败结束 
        public int Percent = 0;//完成百分比 
        public DateTime StartTime;
        public DateTime FinishTime;
        public DateTime ErrorTime;
        /// <summary>
        /// 抽取短信到通道
        /// </summary>
        public void runworkTask()
        {
            LogNet.LogBLL.info("自动提取待发送短信500条上限开始");
            lock (this)
            {
                System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(SendToTask));
                thread.IsBackground = true;
                thread.Start();
            }
            LogNet.LogBLL.info("自动提取待发送短信500条上限结束");

        }
        /// <summary>
        /// 向用户发送短信
        /// </summary>
        public void runworkTarget()
        {
            LogNet.LogBLL.info("平台发送短信500条上限开始");
            lock (this)
            {
                System.Threading.Thread thread2 = new System.Threading.Thread(new System.Threading.ThreadStart(Send2target));
                thread2.IsBackground = true;
                thread2.Start();

            }
            LogNet.LogBLL.info("平台发送短信500条上限结束");
        }
        private void SendToTask()
        {
            try
            {
                 
                   // SMSServer.SendToTaskTransaction(200, basic.GetGuid());
                    SMSServer.SendToTask(100, basic.GetGuid());
                
            }
            catch (Exception e)
            {
                LogNet.LogBLL.warn(e.Message);
            }
        }
        private void Send2target()
        {
            try
            {
                SMSServer.Send2target(100, basic.GetGuid());
            }
            catch (Exception e)
            {
                LogNet.LogBLL.warn(e.Message);
            }


        }
    }
}